﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BrnMall.Manager.Domain.Product;

namespace BrnMall.Manager.Manager.Product
{
    public static class TimeProductManager
    {
        public static void AddTimeProductSetting(TimeProductSetting setting)
        {
            using (var db = new QDMallDatabase())
            {
                db.Insert(setting);
            }
        }

        public static void UpdateTimeProductSetting(TimeProductSetting setting)
        {
            using (var db = new QDMallDatabase())
            {
                db.Update(setting);
            }
        }

        public static TimeProductSetting GetTimeProductSettingByStoreId(int storeId)
        {
            if (storeId < 1)
                throw new ArgumentNullException(nameof(storeId));
            using (var db = new QDMallDatabase())
            {
                return db.SingleOrDefault<TimeProductSetting>("select top 1 * from bma_TimeProductsSetting where storeid=@0",
                    storeId);
            }
        }
    }
}
